<script setup>
import { ref, onMounted, computed } from 'vue'
import { useRouter } from 'vue-router'
import axios from 'axios'

const router = useRouter()
const currentSlide = ref(0)
const events = ref([])
const courses = ref([
  {
    id: 1,
    title: '老年人健康管理课程',
    description: '专业的健康管理指导，助您安享健康生活',
    category: '健康管理',
    image_url: '/uploads/courses/image/image1.jpg',
    enrolled: 128,
    rating: 4.8,
  },
  {
    id: 2,
    title: '老年人营养膳食课程',
    description: '科学的营养搭配，为您定制专属营养方案',
    category: '营养调理',
    image_url: '/uploads/courses/image/image2.jpg',
    enrolled: 156,
    rating: 4.9,
  },
  {
    id: 3,
    title: '老年人运动康复课程',
    description: '专业的运动指导，帮助您保持身心健康',
    category: '康复训练',
    image_url: '/uploads/courses/image/image3.jpg',
    enrolled: 98,
    rating: 4.7,
  }
])
const knowledge = ref([])

// 轮播图数据
const slides = [
  {
    url: 'https://images.unsplash.com/photo-1576765608535-5f04d1e3f289?w=1200',
  },
  {
    url: 'https://images.unsplash.com/photo-1612349317150-e413f6a5b16d?w=1200',
  },
]

const nextSlide = () => {
  currentSlide.value = (currentSlide.value + 1) % slides.length
}

const prevSlide = () => {
  currentSlide.value = (currentSlide.value - 1 + slides.length) % slides.length
}

// 自动轮播
let slideInterval
const startSlideShow = () => {
  slideInterval = setInterval(nextSlide, 5000)
}

const stopSlideShow = () => {
  clearInterval(slideInterval)
}

onMounted(() => {
  startSlideShow()
  fetchEvents()
  fetchCourses()
  fetchKnowledge()
})

const fetchEvents = async () => {
  try {
    const response = await axios.get('http://localhost:3000/api/events')
    events.value = response.data.slice(0, 3)
  } catch (error) {
    console.error('获取活动列表失败:', error)
  }
}

const fetchCourses = async () => {
  try {
    const response = await axios.get('http://localhost:3000/api/courses')
    courses.value = response.data.slice(0, 3)
  } catch (error) {
    console.error('获取课程列表失败:', error)
  }
}

const fetchKnowledge = async () => {
  try {
    const response = await axios.get('http://localhost:3000/api/knowledge')
    knowledge.value = response.data.slice(0, 2)
  } catch (error) {
    console.error('获取养老知识列表失败:', error)
  }
}

const formatDate = (dateString) => {
  return new Date(dateString).toLocaleDateString('zh-CN')
}

const formatDay = (dateString) => {
  return new Date(dateString).getDate();
}

const formatMonth = (dateString) => {
  return new Date(dateString).toLocaleString('zh-CN', { month: 'short' });
}

// 处理活动卡片点击
const handleEventClick = (eventId) => {
  router.push({
    name: 'event-detail',  // 确保路由配置中有这个名称
    params: { id: eventId }
  })
}

// 处理知识卡片点击
const handleKnowledgeClick = (articleId) => {
  router.push({
    name: 'knowledge-detail',  // 确保路由配置中有这个名称
    params: { id: articleId }
  })
}

// 添加处理图片URL的方法
const getImageUrl = (imageUrls) => {
  if (imageUrls && imageUrls.length > 0) {
    return `http://localhost:3000${imageUrls[0]}`
  }
  return '/default-event.jpg'
}

// 修改处理课程图片URL的方法
const getCourseImageUrl = (imageUrl) => {
  if (imageUrl) {
    // 如果已经是完整的URL路径，直接返回
    if (imageUrl.startsWith('/uploads/')) {
      return `http://localhost:3000${imageUrl}`
    }
    // 否则构建完整路径
    return `http://localhost:3000/uploads/courses/image/${imageUrl}`
  }
  return 'https://via.placeholder.com/300x200'
}
</script>

<template>

  <div class="home">
    <NavHeader />
    <!-- 轮播图部分 -->
    <div class="carousel" @mouseenter="stopSlideShow" @mouseleave="startSlideShow">
      <div class="carousel-inner" :style="{ transform: `translateX(-${currentSlide * 100}%)` }">
        <div v-for="(slide, index) in slides" :key="index" class="carousel-slide">
          <img :src="slide.url" alt="养老院图片" />
          <div class="carousel-overlay">
            <h1>专业的养老服务，温馨的生活环境</h1>
            <p>让每一位老人都能安享幸福晚年</p>
          </div>
        </div>
      </div>
      <button class="carousel-btn prev" @click="prevSlide">❮</button>
      <button class="carousel-btn next" @click="nextSlide">❯</button>
      <div class="carousel-dots">
        <span v-for="(_, index) in slides" :key="index" :class="{ active: currentSlide === index }"
          @click="currentSlide = index"></span>
      </div>
    </div>

    <!-- 服务内容卡片 -->
    <div class="service-cards">
      <div class="service-card" @click="router.push('/consultation')">
        <div class="icon">
          <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 24 24" fill="none"
            stroke="currentColor" stroke-width="2">
            <path d="M22 12h-4l-3 9L9 3l-3 9H2"></path>
          </svg>
        </div>
        <h3>专业问诊</h3>
        <p>提供24小时专业医疗咨询，配备专业医护团队，全方位守护老年人健康</p>
      </div>
      <div class="service-card" @click="router.push('/events')">
        <div class="icon">
          <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 24 24" fill="none"
            stroke="currentColor" stroke-width="2">
            <circle cx="12" cy="12" r="10"></circle>
            <path d="M12 6v6l4 2"></path>
          </svg>
        </div>
        <h3>康养活动</h3>
        <p>科学规划康养活动，专业指导师团队，促进身心健康，提升生活品质</p>
      </div>
      <div class="service-card" @click="router.push('/knowledge')">
        <div class="icon">
          <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 24 24" fill="none"
            stroke="currentColor" stroke-width="2">
            <path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"></path>
            <path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"></path>
          </svg>
        </div>
        <h3>养老知识</h3>
        <p>提供专业养老知识库，涵盖健康管理、营养调理、心理关怀等全面指导</p>
      </div>
    </div>

    <!-- 精彩活动部分 -->
    <div class="section events-section">
      <h2 class="section-title">
        精彩活动
        <span class="subtitle">丰富多彩的活动安排</span>
      </h2>
      <div class="events-grid">
        <div v-for="event in events" :key="event.id" class="event-card" @click="$router.push(`/event/${event.id}`)">
          <div class="event-image" :style="{ backgroundImage: `url(${getImageUrl(event.image_url)})` }">
            <div class="event-date">
              <span class="day">{{ formatDay(event.date) }}</span>
              <span class="month">{{ formatMonth(event.date) }}</span>
            </div>
          </div>
          <div class="event-content">
            <h3>{{ event.name }}</h3>
            <p class="description">{{ event.description }}</p>
            <div class="event-info">
              <span class="location">
                <i class="el-icon-location"></i>
                {{ event.location }}
              </span>
              <span class="participants">
                <i class="el-icon-user"></i>
                已报名: {{ event.participants || 0 }}
              </span>
            </div>
            <button class="event-button">查看详情</button>
          </div>
        </div>
      </div>
    </div>

    <!-- 精选好课部分 -->
    <div class="section courses-section">
      <h2 class="section-title">
        精选好课
        <span class="subtitle">专业的养老课程</span>
      </h2>
      <div class="courses-grid">
        <div v-for="course in courses" :key="course.id" class="course-card"
          @click="$router.push(`/course/${course.id}`)">
          <div class="course-content">
            <div class="course-category">{{ course.category || '养老课程' }}</div>
            <h3>{{ course.title }}</h3>
            <p class="description">{{ course.description }}</p>
            <div class="course-info">
              <div class="stats">
                <span><i class="el-icon-user"></i> {{ course.enrolled || 0 }}人已学习</span>
                <span><i class="el-icon-star-off"></i> {{ course.rating || 4.5 }}分</span>
              </div>
              <button class="course-button">立即学习</button>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 养老知识部分 -->
    <div class="section knowledge-section">
      <h2 class="section-title">
        养老知识
        <span class="subtitle">专业的养老指导</span>
      </h2>
      <div class="knowledge-grid">
        <div v-for="article in knowledge" :key="article.id" class="knowledge-card"
          @click="$router.push(`/knowledge/${article.id}`)">
          <div class="knowledge-content">
            <div class="knowledge-category">{{ article.category || '健康知识' }}</div>
            <h3>{{ article.title }}</h3>
            <p class="description">{{ article.content }}</p>
          </div>
          <div class="knowledge-footer">
            <div class="stats">
              <span><i class="el-icon-view"></i> {{ article.views || 0 }}</span>
              <span><i class="el-icon-star-off"></i> {{ article.likes || 0 }}</span>
            </div>
            <div class="read-more">
              阅读更多 <i class="el-icon-right"></i>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.home {
  width: 100%;
  background-color: #f5f7fa;
  min-height: 100vh;
  height: auto;
  position: relative;
  overflow-y: visible;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

/* 轮播图样式 */
.carousel {
  position: relative;
  width: 100%;
  height: 500px;
  overflow: hidden;
}

.carousel-inner {
  display: flex;
  transition: transform 0.5s ease-in-out;
  height: 100%;
}

.carousel-slide {
  min-width: 100%;
  position: relative;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slide-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: white;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.3);
  border: none;
  color: white;
  padding: 16px;
  cursor: pointer;
  font-size: 18px;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.carousel-btn:hover {
  background: rgba(255, 255, 255, 0.5);
}

.prev {
  left: 10px;
}

.next {
  right: 10px;
}

.carousel-dots {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}

.carousel-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 0.3s ease;
}

.carousel-dots span.active {
  background: white;
  transform: scale(1.2);
}

/* 服务卡片样式 */
.service-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 30px;
  padding: 40px;
  max-width: 1200px;
  margin: -60px auto 0;
  position: relative;
  z-index: 2;
}

.service-card {
  background: #ffffff;
  border: 1px solid rgba(44, 62, 80, 0.1);
  padding: 35px 25px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(44, 62, 80, 0.08);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.service-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #2c3e50, #3498db);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.service-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 30px rgba(44, 62, 80, 0.12);
}

.service-card:hover::before {
  opacity: 1;
}

.icon {
  margin-bottom: 20px;
  color: #2c3e50;
  transition: all 0.3s ease;
}

.service-card:hover .icon {
  color: #3498db;
}

.service-card h3 {
  color: #2c3e50;
  font-size: 1.4em;
  font-weight: 600;
  margin-bottom: 15px;
  position: relative;
}

.service-card p {
  color: #5f6c7b;
  line-height: 1.6;
  font-size: 0.95em;
  margin: 0;
}

/* 内容区域样式 */
.content-section {
  max-width: 1200px;
  margin: 30px auto;
  padding: 20px 40px;
  position: relative;
  z-index: 1;
}

.section-title {
  text-align: center;
  margin-bottom: 30px;
}

.section-title h2 {
  font-size: 1.8em;
  margin-bottom: 15px;
  color: #2c3e50;
  font-weight: 600;
  position: relative;
  display: inline-block;
}

.section-title h2::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, #20b2aa, #3498db);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.content-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  background: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.content-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(32, 178, 170, 0.15);
}

.content-card h3 {
  font-size: 1.3em;
  font-weight: 600;
  margin-bottom: 12px;
  color: #2c3e50;
}

.content-card p {
  color: #666;
  line-height: 1.6;
  margin-bottom: 15px;
  font-size: 0.95em;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  color: #20b2aa;
  font-size: 0.9em;
  padding-top: 15px;
  border-top: 1px solid rgba(32, 178, 170, 0.1);
}

.module-section {
  margin-bottom: 60px;
}

.module-section:last-child {
  margin-bottom: 0;
}

.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.knowledge-card {
  cursor: pointer;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.knowledge-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(32, 178, 170, 0.15);
}

.knowledge-content {
  flex: 1;
  padding: 20px;
}

.knowledge-content h3 {
  font-size: 1.2em;
  font-weight: 600;
  margin-bottom: 12px;
  color: #2c3e50;
  line-height: 1.4;
}

.knowledge-content p {
  color: #666;
  line-height: 1.6;
  margin-bottom: 0;
}

.knowledge-footer {
  padding: 10px 20px;
  border-top: 1px solid rgba(32, 178, 170, 0.1);
}

.read-more {
  color: #20b2aa;
  font-size: 0.9em;
  font-weight: 500;
  transition: all 0.3s ease;
}

.knowledge-card:hover .read-more {
  color: #3498db;
  transform: translateX(5px);
}

/* 优化轮播图样式 */
.carousel-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.5));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  text-align: center;
  padding: 0 20px;
}

.carousel-overlay h1 {
  font-size: 2.8em;
  font-weight: 600;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.carousel-overlay p {
  font-size: 1.4em;
  opacity: 0.9;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* 页脚样式 */
.footer {
  background: linear-gradient(to right, #2c3e50, #3498db);
  color: white;
  padding: 20px 0 0;
  margin-top: 40px;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 0 40px 20px;
}

.footer-section {
  display: flex;
  flex-direction: column;
}

.footer-section h3 {
  font-size: 16px;
  margin-bottom: 15px;
  position: relative;
  padding-bottom: 8px;
}

.footer-section h3::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 30px;
  height: 2px;
  background: rgba(255, 255, 255, 0.4);
}

.contact-info p {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.quick-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.quick-links li {
  margin-bottom: 8px;
}

.quick-links a {
  color: white;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.3s ease;
  display: inline-block;
}

.quick-links a:hover {
  opacity: 0.8;
}

.qrcode-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.qrcode {
  width: 80px;
  height: 80px;
  background: white;
  padding: 6px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.qrcode img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qrcode-wrapper p {
  font-size: 14px;
  margin: 0;
}

.footer-bottom {
  background: rgba(0, 0, 0, 0.2);
  text-align: center;
  padding: 12px;
  margin-top: 15px;
}

.footer-bottom p {
  margin: 0;
  font-size: 14px;
  opacity: 0.8;
}

@media (max-width: 768px) {
  .footer {
    padding: 20px 0 0;
  }

  .footer-content {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 0 20px 15px;
  }

  .footer-section {
    align-items: center;
    text-align: center;
  }

  .footer-section h3::after {
    left: 50%;
    transform: translateX(-50%);
  }

  .contact-info {
    align-items: center;
  }

  .quick-links {
    text-align: center;
  }

  .qrcode {
    width: 100px;
    height: 100px;
  }
}

/* 响应式调整 */
@media (max-width: 768px) {
  .carousel {
    height: 300px;
  }

  .service-cards {
    grid-template-columns: 1fr;
    margin-top: -30px;
    padding: 20px;
  }

  .content-section {
    padding: 15px 20px;
  }

  .section-title h2 {
    font-size: 1.5em;
  }

  .carousel-btn {
    padding: 10px;
    font-size: 14px;
  }

  .module-section {
    margin-bottom: 40px;
  }

  .knowledge-grid {
    grid-template-columns: 1fr;
  }

  .carousel-overlay h1 {
    font-size: 1.8em;
  }

  .carousel-overlay p {
    font-size: 1.1em;
  }

  .footer {
    padding: 15px 0 0;
    margin-top: 20px;
  }

  .footer-content {
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 0 15px 10px;
  }

  .card-grid,
  .knowledge-grid {
    grid-template-columns: 1fr;
  }

  .service-card {
    padding: 25px 20px;
  }
}

.section {
  margin: 40px 0;
}

.section-title {
  text-align: center;
  color: #2c3e50;
  font-size: 24px;
  margin-bottom: 30px;
  position: relative;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  background-color: var(--el-color-primary);
}

.events-grid,
.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  padding: 0 20px;
}

.event-card,
.knowledge-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.event-card:hover,
.knowledge-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(44, 62, 80, 0.12);
}

.event-card h3,
.knowledge-card h3 {
  font-size: 18px;
  color: #2c3e50;
  margin-bottom: 10px;
}

.description {
  color: #666;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 15px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event-info {
  display: flex;
  justify-content: space-between;
  color: var(--el-color-primary);
  font-size: 14px;
}

.read-more {
  text-align: right;
  color: var(--el-color-primary);
  font-size: 14px;
}

.read-more span {
  cursor: pointer;
}

@media (max-width: 768px) {

  .events-grid,
  .knowledge-grid {
    grid-template-columns: 1fr;
    padding: 0 15px;
  }
}

/* 通用部分样式优化 */
.section {
  padding: 60px 20px;
  background: #f8f9fa;
}

.section-title {
  text-align: center;
  margin-bottom: 40px;
  color: #2c3e50;
  position: relative;
  font-size: 32px;
  font-weight: 600;
}

.section-title .subtitle {
  display: block;
  font-size: 16px;
  color: #666;
  margin-top: 8px;
  font-weight: normal;
}

/* 活动卡片样式优化 */
.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 30px;
  max-width: 1200px;
  margin: 0 auto;
}

.event-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  position: relative;
}

.event-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.event-image {
  height: 200px;
  background-size: cover;
  background-position: center;
  position: relative;
}

.event-date {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.9);
  padding: 10px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.event-date .day {
  display: block;
  font-size: 24px;
  font-weight: bold;
  color: #2c3e50;
}

.event-date .month {
  display: block;
  font-size: 14px;
  color: #666;
}

.event-content {
  padding: 20px;
}

.event-content h3 {
  font-size: 20px;
  color: #2c3e50;
  margin-bottom: 12px;
}

.event-info {
  display: flex;
  justify-content: space-between;
  margin: 15px 0;
  color: #666;
  font-size: 14px;
}

.event-button {
  width: 100%;
  padding: 12px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.event-button:hover {
  background: #2980b9;
}

/* 知识卡片样式优化 */
.knowledge-section {
  background: #fff;
}

.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  max-width: 1200px;
  margin: 0 auto;
}

.knowledge-card {
  background: white;
  border-radius: 12px;
  border: 1px solid #eee;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.knowledge-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.knowledge-content {
  padding: 25px;
  flex: 1;
}

.knowledge-category {
  display: inline-block;
  padding: 4px 12px;
  background: #e3f2fd;
  color: #1976d2;
  border-radius: 20px;
  font-size: 12px;
  margin-bottom: 15px;
}

.knowledge-content h3 {
  font-size: 20px;
  color: #2c3e50;
  margin-bottom: 12px;
  line-height: 1.4;
}

.knowledge-footer {
  padding: 15px 25px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
}

.stats {
  display: flex;
  gap: 15px;
  color: #666;
  font-size: 14px;
}

.stats span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.read-more {
  color: #3498db;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.3s ease;
}

.knowledge-card:hover .read-more {
  color: #2980b9;
  transform: translateX(5px);
}

/* 响应式优化 */
@media (max-width: 768px) {
  .section {
    padding: 40px 15px;
  }

  .section-title {
    font-size: 24px;
  }

  .events-grid,
  .knowledge-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .event-image {
    height: 180px;
  }
}

/* 课程卡片样式 */
.courses-section {
  background: #f8f9fa;
  padding: 60px 20px;
}

.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 30px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px;
}

.course-card {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  padding: 30px;
  border: 1px solid #f0f0f0;
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.course-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  border-color: var(--el-color-primary-light-7);
}

.course-category {
  display: inline-block;
  padding: 8px 16px;
  background: var(--el-color-primary-light-9);
  color: var(--el-color-primary);
  border-radius: 20px;
  font-size: 13px;
  margin-bottom: 20px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.course-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.course-content h3 {
  font-size: 22px;
  color: #1a1a1a;
  margin-bottom: 16px;
  line-height: 1.4;
  font-weight: 600;
  transition: color 0.3s ease;
}

.course-card:hover .course-content h3 {
  color: var(--el-color-primary);
}

.description {
  color: #666;
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 25px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 48px;
}

.course-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid #f5f5f5;
}

.course-info .stats {
  display: flex;
  gap: 20px;
  color: #666;
  font-size: 14px;
}

.course-info .stats span {
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.3s ease;
}

.course-info .stats span:hover {
  color: var(--el-color-primary);
}

.course-button {
  padding: 10px 24px;
  background: var(--el-color-primary);
  color: white;
  border: none;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(24, 144, 255, 0.15);
}

.course-button:hover {
  background: var(--el-color-primary-dark-2);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(24, 144, 255, 0.25);
}

/* 响应式优化 */
@media (max-width: 768px) {
  .courses-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 5px;
  }

  .course-card {
    padding: 20px;
  }

  .course-category {
    padding: 6px 12px;
    font-size: 12px;
    margin-bottom: 15px;
  }

  .course-content h3 {
    font-size: 18px;
    margin-bottom: 12px;
  }

  .description {
    font-size: 14px;
    margin-bottom: 20px;
  }

  .course-info {
    padding-top: 15px;
  }

  .course-button {
    padding: 8px 20px;
    font-size: 13px;
  }
}
</style>
